<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位</title>
    <style>
        body {
            height: 3000px;
        }
        div {
            width: 100px;
            height: 100px;
        }
        .core {
            width: 900px;
            height: 950px;
            margin: 0 auto;
            background-color: slategray;
        }
        .box1 {
            position: relative;
            top: 20px;
            left: 20px;
            background-color: slategray;
        }
        .box2 {
            background-color: rgb(57, 67, 78);
        }
        .box3 {
            position: absolute;
            top: 30px;
            right: 20px;
            width: 30px;
            height: 30px;
            background-color: rgb(107, 150, 192);
        }
        .box4 {
            position: fixed;
            left: 50%;
            margin-left: 450px;
            height: 50px;
            width: 50px;
            background-color: springgreen;
        }
        .box5 {
            position: sticky;
            top: 0;
            background-color: steelblue;
        }
        .box6 {
            position: absolute;
            right: 20px;
            top: 30px;
            z-index: 2;
            background-color: brown;
        }
        .box7 {
            position: absolute;
            right: 30px;
            top: 40px;
            z-index: 3;
            background-color: lightseagreen;
        }
        .box8 {
            position: absolute;
            right: 10px;
            top: 20px;
            z-index: 1;
            background-color: seagreen;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="box3"></div>
    </div>
    <div class="box2"></div>
    <div class="box4"></div>
    <div class="core">版心</div>
    <div class="box5">粘性定位</div>
    <div class="box6">z-index</div>
    <div class="box7">z-index</div>
    <div class="box8">z-index</div>
</body>
</html>

